home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
sea of chaos
/
sea_install.msi
/
_15C39AAA7726369D39812BD40F01CF6A
/
_4459DEF3A62245078ED2A81EF23C18BE
< prev
next >
Wrap
Text File
|
2005-03-09
|
1KB
|
49 lines
///basic particle shader
//input should be 4 points that are the same, tex coord will expand them in screen space
//Luke Lenhart
//(C)2004-2005 Digipen Institute of Technology
//world,view,projection transform
float4x4 matViewProj;
//camera position in world space
float4 cameraPos;
//particle size modifier
float size;
//shader input
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float2 Tex0 : TEXCOORD0;
};
//shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float2 Tex0 : TEXCOORD0;
};
//shader code
VS_OUTPUT VShader(VS_INPUT In)
{
VS_OUTPUT Out;
//transform pos and copy tex coord and color over
Out.Pos=mul(matViewProj,In.Pos);
Out.Tex0=In.Tex0;
Out.Color=In.Color;
//expand outwards from center point, based on distance and tex coord
float dist=distance(cameraPos,In.Pos);
Out.Pos.xy+=(1.0f/sqrt(dist))*(In.Tex0-0.5f)*size;
//spit out the results
return Out;
}